package com.xbs.dao.selfdriving;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.xbs.dao.conn.BaseDao;
import com.xbs.dao.conn.RowDatas;
import com.xbs.entity.CarEntity;
import com.xbs.entity.CarModelEntity;

/**
 * 自驾租车Dao类
 * @author Administrator
 *
 */
public class CarDao extends BaseDao{

	private RowDatas<CarEntity> car;   //声明一个车对象结果处理对象
	
	public CarDao(){
		car = new carData();  //实例结果处理对象
	}

	/**
	 * 1. 查询车信息
	 * @return
	 */
	public List<CarEntity> getCar(){
		String sql = "select * from tb_car,tb_car_model where tb_car.car_model_id = tb_car_model.car_model_id";
		return queryList(sql,null,car);
	}
	
	/**
	 * 通过内部类实现结果处理接口
	 * @author Administrator
	 *
	 */
	private class carData implements RowDatas<CarEntity>{

		@Override
		public CarEntity getRowData(ResultSet rs) throws SQLException {
			CarEntity car = new CarEntity();
			//给CarEntity赋值
			car.setCarmodelimage(rs.getString("car_model_image"));
			car.setCarmodeltype(rs.getString("car_model_type"));
			car.setCarmodelname(rs.getString("car_model_name"));
			car.setSeating(rs.getInt("car_model_seating"));
			car.setRentcash(rs.getDouble("car_model_rent_cash"));
			return car;
		}
		
	}
}
